import React from 'react';
import { connect } from 'react-redux';

import * as actions from '../actions';
import WedPage from './WedPage';
import ProjectTag from './ProjectTag';


/**
 * main 容器组件
 *
 * @class TagMain
 * @extends {Component}
 */
class TagMain extends React.Component{
    constructor(props){
        super(props)
        this.state = {
            pageNum:1
        }
    }

    selectPage(type){
        this.setState({
          pageNum:type
        })
    }

    render(){
        const { pageNum } = this.state;
        return(
            <div className="bear-manage-tag">
                <div className="center-box select-head">
                    <span className={"center-box " + (pageNum == 1 ? 'active-b' : '')} onClick={()=>this.selectPage(1)}>方案标签</span>
                    <span className={"center-box " + (pageNum == 2 ? 'active-b' : '')} onClick={()=>this.selectPage(2)}>婚礼标签</span>
                </div>
                {pageNum === 1 ? <ProjectTag {...this.props}/> : <WedPage {...this.props}/>}
            </div>
        )
    }
}

const mapStateToProps = (state)=>{
    const currentRoot = state.bearManage.tagReducer;
    return {
        tagListData:currentRoot.get('tagListData'),
        wedTypeListData:currentRoot.get('wedTypeList'),
    }
}

export default connect(mapStateToProps,actions)(TagMain);
